package com.example.demo.vos;

import lombok.Data;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletResponse;

@Data
public class ResultVo<T> {
    private Integer code;//
    private String message;
    private T t;

    public ResultVo() {
    }

    public ResultVo(Integer code, String message, T t) {
        this.code = code;
        this.message = message;
        this.t = t;
    }
    public ResultVo(Integer code, T t) {
        this.code = code;
        this.t = t;
    }
    public ResultVo(String message, T t) {
        this.message = message;
        this.t = t;
    }

    @ResponseBody
    public static <T> ResultVo success(T t, HttpServletResponse response) {
        response.setContentType("application/json;charset=UTF-8");
        return new ResultVo<T>(6000, "成功", t);
    }

    public static <T> ResultVo success(T t){
        return new ResultVo<T>(6000,"成功",t);
    }

    public static <T> ResultVo success(String message,T t){
        return new ResultVo<T>(6000,message,t);
    }

    public static <T> ResultVo error(){
        return new ResultVo(7000,"error");
    }

    public static <T> ResultVo error(String message){
        return new ResultVo(7000,message);
    }

    public static ResultVo failure(String 任务不存在) {
        return null;
    }


}